﻿using System;
using System.Collections.Generic;
using System.Web;
using PayRoller.Code;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using HySoft.Cash.Business;
using HySoft.Cash.Structure;
using System.Configuration;
using System.Web.Profile;
using System.Data;

namespace PayRoller.Manage.QuickAdd
{
    public class Receipt : ParentPage, IRequiresSessionState
    {
        // Fields
        protected Button btnEdit;
        protected TextBox txtOrgName;
        protected HtmlForm form1;
        protected HtmlHead Head1;

        // Methods
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            string orgNameGetted = this.txtOrgName.Text;
            if (string.IsNullOrEmpty(orgNameGetted) == false)
            {
                if (orgNameGetted.Contains("[") && orgNameGetted.Contains("]"))
                {
                    int beginPos = orgNameGetted.LastIndexOf("[") +1;
                    int endPos = orgNameGetted.LastIndexOf("]");
                    string orgID = orgNameGetted.Substring(beginPos,endPos-beginPos);
                    if (orgID != string.Empty)
                    {
                        base.Response.Redirect("ReceivingList.aspx?OrgSid=" + orgID);
                    }
                }
            }
            else
            { 
                
            }
            //if (this.dlOrg.SelectedValue != "-1")
            //{
            //    base.Response.Redirect("ReceivingList.aspx?OrgSid=" + this.dlOrg.SelectedValue);
            //}
        }

        //public void GetOrgList()
        //{
        //    TorginfoBN obn = new TorginfoBN(this.Page);
        //    DataTable list = obn.GetList();
        //    obn.Dispose();
        //    obn = null;
        //    ListItem item = new ListItem("Please select client", "-1");
        //    this.dlOrg.Items.Add(item);
        //    for (int i = 0; i < list.Rows.Count; i++)
        //    {
        //        item = new ListItem(list.Rows[i]["OrgName"].ToString(), list.Rows[i]["Sid"].ToString());
        //        this.dlOrg.Items.Add(item);
        //    }
        //}

        protected override void OnInit(EventArgs e)
        {
            base.m_ModuleCode = "0007";
            base.CheckLogin(true);
            base.CheckPerm();
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                //this.GetOrgList();
            }
        }

        // Properties
        protected HttpApplication ApplicationInstance
        {
            get
            {
                return this.Context.ApplicationInstance;
            }
        }

        protected DefaultProfile Profile
        {
            get
            {
                return (DefaultProfile)this.Context.Profile;
            }
        }
    }

}
